<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title></title>  
<style type="text/css">
   .main {border:1px solid red;width:800px;}
   .main .title{border:1px solid blue;height:42px;}
   .main .photo{border:1px solid blue;height:500px;text-align: center;}
   //.main .photo img { border: medium none; height: 100%;margin: 0; padding: 0;vertical-align: middle;}
</style>
<script type="text/javascript">
function ReSizePic(ThisPic){
    var RePicWidth = 400; //这里修改为您想显示的宽度值

    //============以下代码请勿修改==================================

    var TrueWidth = ThisPic.width;    //图片实际宽度
    var TrueHeight = ThisPic.height;  //图片实际高度
    var Multiple = TrueWidth / RePicWidth;  //图片缩小(放大)的倍数

    ThisPic.width = RePicWidth;  //图片显示的可视宽度
    var h=TrueHeight / Multiple;
    (h>500)&&(h=500)
    ThisPic.height = h;  //图片显示的可视高度
}
</script>
</head>  
<body>  
    <div class="main">
       <div class="title"></div>
       <div class="photo">
         <img src="http://img6.cache.netease.com/photo/0001/2011-11-15/900x600_7ISK0P0A3R710001.jpg" onload="ReSizePic(this);">
       </div>
    </div>
    
    
</body>  
</html>